package com.swingolf.web;

import com.swingolf.dao.hrd.HRDTeamDAOImpl;
import com.swingolf.model.Team;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

public class TeamConverter implements Converter<String, Team> {

  @Autowired HRDTeamDAOImpl teamDAO;

  public Team convert(String s) {
    if (!StringUtils.hasText(s)) {
      return null;
    }
    Long id = Long.parseLong(s);
    return teamDAO.findById(id);
  }
}
